﻿using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sustainalytics.DataLayer.Shared;
using Sustainalytics.Entities;

namespace Sustainalytics.Portfolios.BL.Tests
{
    [TestClass]
    public class PortfolioDetailsManagementTests
    {
        private IRepositoryCollection<Portfolio> PortfolioRepo { get; set; }
        private IRepositoryCollection<PortfolioDetails> PortfolioDetailsRepo { get; set; }
        private IPortfolioManager PortfolioManager { get; set; }
        //private IPortfolioDetailsManagement PortfolioDetailsManager { get; set; }

        [TestInitialize]
        public void Initialize()
        {
            //Create repository
            PortfolioRepo = new RepositoryCollection<Portfolio>(MongoDbUrl());
            PortfolioDetailsRepo = new RepositoryCollection<PortfolioDetails>(MongoDbUrl());

            //PortfolioTestingData.CleanupPortfolioRepo(this.PortfolioRepo);
            //PortfolioTestingData.CleanupPortfolioDetailsRepo(this.PortfolioDetailsRepo);

            //PortfolioTestingData.InitializeRepo(this.PortfolioRepo);
            //PortfolioTestingData.InitializeRepo(this.PortfolioDetailsRepo);

            //Create BL
            PortfolioManager = new PortfolioManager(PortfolioRepo, PortfolioDetailsRepo,new RepositoryCollection<PortfolioUserInput>(MongoDbUrl()));
            //this.PortfolioDetailsManager = new PortfolioDetailsManagement(this.PortfolioDetailsRepo);
        }

        private static string MongoDbUrl()
        {
            return ConfigurationManager.ConnectionStrings["ClientPlatform_Test"].ConnectionString;
        }

    

        //[TestMethod]
        //[ExpectedException(typeof(PortfolioDetailsInsertUnauthorisedException))]
        //public void InsertPortfolioDetails_Unauthorized()
        //{
        //    PortfolioUserClaims userClaims = new PortfolioUserClaims();
        //    userClaims.UserName = "ileana@sustainalytics.com";
        //    userClaims.UserFullName = "Ileana";
        //    userClaims.UserId = new Guid("1387c2a7-1eda-11e4-92ce-6c3be5be9f98");
        //    userClaims.AccountId = new Guid("528ea769-2d17-e411-92ce-6c3be5be9f98");

        //    Guid portfolioId = Guid.Parse("00000000-0000-0000-0000-" + "011".PadLeft(12, '0'));
        //    //Guid securityId = Guid.Parse("00000000-0000-0000-0000-" + "009".PadLeft(12, '0'));
        //    PortfolioDetails test = new PortfolioDetails()
        //    {
        //        SecurityId = 1,
        //    };
        //    this.PortfolioManager.AddSecurityToPortfolio(portfolioId, test, userClaims);
        //}
    }
}
